﻿using OneSoft.DataAccess;
using OneSoft.EntityCore;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BySoft.Server.DataAccess.UserCode
{
    public partial class MdProductDataAccess
    {
        public static DataTable SelectDialogList(string ProductID, string ProductName, int pageIndex, int pageSize, out int m_count)
        {
            try
            {
                #region SQL Server
                string strcmd = @"SELECT a.*,pt.ProductTypeName
                                    FROM MD_Product a 
                                    left join MD_ProductType pt on pt.ProductTypeID=a.ProductTypeID
                                    where 1=1";

                DataAccessParameterCollection dpc = new DataAccessParameterCollection();

                if (!string.IsNullOrEmpty(ProductID))
                {
                    strcmd += " and a.ProductID LIKE @ProductID";
                    dpc.AddWithValue("@ProductID", "%" + ProductID + "%");
                }

                if (!string.IsNullOrEmpty(ProductName))
                {
                    strcmd += " and a.ProductName LIKE @ProductName";
                    dpc.AddWithValue("@ProductName", "%" + ProductName + "%");
                }

                strcmd += " ORDER BY a.ProductID DESC";
                return DataAccessCommon.ExecuteDataTablePaging(strcmd, pageIndex, pageSize, dpc, out m_count);
                #endregion
            }
            catch
            {
                throw;
            }
        }
    }
}
